import request from './request'

/**
 * 获取病房列表
 */
export function getWardList(params) {
  return request({
    url: '/wards',
    method: 'get',
    params
  })
}

/**
 * 获取病房详情
 */
export function getWardDetail(wardId) {
  return request({
    url: `/wards/${wardId}`,
    method: 'get'
  })
}

/**
 * 创建病房
 */
export function createWard(data) {
  return request({
    url: '/wards',
    method: 'post',
    data
  })
}

/**
 * 更新病房
 */
export function updateWard(wardId, data) {
  return request({
    url: `/wards/${wardId}`,
    method: 'put',
    data
  })
}

/**
 * 删除病房
 */
export function deleteWard(wardId) {
  return request({
    url: `/wards/${wardId}`,
    method: 'delete'
  })
}

/**
 * 获取病房的床位列表
 */
export function getWardBeds(wardId) {
  return request({
    url: `/wards/${wardId}/beds`,
    method: 'get'
  })
}

/**
 * 创建床位
 */
export function createBed(wardId, data) {
  return request({
    url: `/wards/${wardId}/beds`,
    method: 'post',
    data
  })
}

/**
 * 更新床位
 */
export function updateBed(wardId, bedId, data) {
  return request({
    url: `/wards/${wardId}/beds/${bedId}`,
    method: 'put',
    data
  })
}

/**
 * 删除床位
 */
export function deleteBed(wardId, bedId) {
  return request({
    url: `/wards/${wardId}/beds/${bedId}`,
    method: 'delete'
  })
}

/**
 * 绑定设备到床位
 */
export function bindDeviceToBed(wardId, bedId, deviceId) {
  return request({
    url: `/wards/${wardId}/beds/${bedId}/bind`,
    method: 'post',
    data: { deviceId }
  })
}

/**
 * 解绑床位的设备
 */
export function unbindDeviceFromBed(wardId, bedId) {
  return request({
    url: `/wards/${wardId}/beds/${bedId}/unbind`,
    method: 'post'
  })
}

